<?
session_start();
header('Content-type: text/html;charset=utf-8');
include('../db_info.php');
include('baze_count.php');
count_me();

//print_r($_POST);

if (isset($_POST['sub']))
{
	$sql="select * from managers where login='".$_POST['login']."' and password='".$_POST['password']."' ";
	if(!$result = $GLOBALS['mysqli_conn1']->query($sql))
	{
		echo "<br>".$sql;
		exit();
	};
	
	if (mysqli_num_rows($result)==1)
	{
		$row = mysqli_fetch_array($result);
		$_SESSION['manager_id']=$row['id'];
		$_SESSION['manager_login']=true;
		$_SESSION['admin']      = $row['admin'];
		$_SESSION['superviser'] = $row['superviser'];
		
		if($_SESSION['admin'] == 1)
			$_SESSION['role_name'] = 'админ';
		else if($_SESSION['superviser'] == 1)
			$_SESSION['role_name'] = 'супервизор';
		else
			$_SESSION['role_name'] = '';
		
		header ("Location: lk.php",true,301);
		
		exit();
	}
	else
	{
		$login_err="<font color='red'>Вы ввели неверные данные.</font>";
	};
	
};

?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1251"/>
    <title>kz-pro.com - Партнерская программа автострахования</title>
    <link type="text/css" rel="stylesheet" href="style.css"/>
    <!--[if lte IE 7]><link type="text/css" rel="stylesheet" href="ie.css" /><![endif]-->
</head>

<body>
    <div class="mainpage">
        <div id="page">
            <div id="header">
                <h1 class="logo"><a href="#" title="kz-pro.com - Партнерская программа автострахования">kz-pro.com - Вход для менеджеров</a></h1>
                <form method="post" class="authForm">
                    <h3><span>Вход</span> в систему</h3><?echo $login_err;?>
                    <div class="fields clearfix">
                        <span class="input_text"><span><span><input name="login" type="text" id="authForm_login" value="введите имя" onfocus="if (this.value==this.title) this.value='';" onblur="if (this.value=='') this.value=this.title;" title="введите имя" /></span></span></span>
                        <span class="input_text"><span><span><input name="password" type="password" id="authForm_passwd" value="пароль" onfocus="if (this.value==this.title) this.value='';" onblur="if (this.value=='') this.value=this.title;" title="пароль" /></span></span></span>
                        <span class="blueBtn"><span><span><input name="sub" type="submit" value="Войти" /></span></span></span>
                    </div>
                    
                </form>
            </div>
        </div>
        <div id="footer_out"><div id="footer">Все права защищены компанией "Kz-pro"</div></div>
    </div>
</body>
</html>
